/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.comunicacion2.model.pathloss;

import com.comunicacion2.model.PathLossModel;

/**
 *
 * @author LangTecnologia
 */
public class TwoRayPathLoss implements PathLossModel{
    
   private final double heightTransmitter;
   private final double heightReciever;
   private final int gainTransmitter;
   private final int powerTransmitter;
   
   public TwoRayPathLoss(double heightTransmitter, double heightReciever, int gainTransmitter, int powerTransmitter){
       this.heightTransmitter = heightTransmitter;
       this.heightReciever = heightReciever;
       this.gainTransmitter = gainTransmitter;
       this.powerTransmitter = powerTransmitter;
   }
    
    public int calculateIntensity(double distance) {
        
        double intensity = powerTransmitter * Math.pow(((Math.sqrt(gainTransmitter) * heightReciever * heightTransmitter))/(Math.pow(distance, 2)), 2);
        
        Double intensityDb = 10 * Math.log10(intensity);
        
        return intensityDb.intValue();
    }
    
}
